home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 051-075 / scopedisk61 / diskfree / diskfree.c < prev    next >
C/C++ Source or Header  |  1995-03-19  |  1KB  |  43 lines

  1. #include <dos.h>          /* get DISKINFO structure */
  2. #include <stdio.h>        /* need for printf */
  3.  
  4. void main(argc,argv)
  5. int argc;
  6. char *argv[];
  7.  
  8. {
  9. struct DISKINFO info;      /* structure needed for getdfs found in <dos,h>*/
  10. long size;                 /* needed to calculate free disk space */
  11. int error;                 /* error = 0 if getdfs is successful */
  12.  
  13.     if(argc != 2)      /* make sure that a drive is specified */
  14.     {
  15.         printf("USAGE: ");          /* print error message if no */
  16.             printf("DFREE [drive] \n"); /* or too many drives given  */
  17.         exit(0);                    /* then exit program */
  18.     }
  19.     
  20.  
  21.     error = getdfs(argv[1],&info);     /* call getdfs,error = 0 if */
  22.                         /* successful */           
  23.     if(error == 0) /* calculate disk free space */
  24.     {
  25.         size = (info.id_NumBlocks - info.id_NumBlocksUsed) 
  26.                 * info.id_BytesPerBlock; 
  27.         
  28.         printf("drive ");           /* print result */
  29.         printf(argv[1]);
  30.         printf(" has ");
  31.         printf("%d",size);
  32.         printf(" bytes free \n");
  33.     }
  34.     else  /* if specified disk isn't found */
  35.     {
  36.         printf(argv[1]);
  37.         printf(" not found \n");
  38.     }
  39. }
  40.  
  41.  
  42.  
  43.